﻿CREATE TABLE [dbo].[Inventory] (
    [LocationId] UNIQUEIDENTIFIER NOT NULL,
    [ItemId]     UNIQUEIDENTIFIER NOT NULL,
    [UnitId]     UNIQUEIDENTIFIER NOT NULL,
    [Onhand]     DECIMAL (19, 6)  CONSTRAINT [DF_Inventory_Onhand] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Inventory_1] PRIMARY KEY CLUSTERED ([LocationId] ASC, [ItemId] ASC, [UnitId] ASC),
    CONSTRAINT [FK_Inventory_Item] FOREIGN KEY ([ItemId]) REFERENCES [dbo].[Item] ([Id]),
    CONSTRAINT [FK_Inventory_Location] FOREIGN KEY ([LocationId]) REFERENCES [dbo].[Location] ([Id]),
    CONSTRAINT [FK_Inventory_Unit] FOREIGN KEY ([UnitId]) REFERENCES [dbo].[Unit] ([Id])
);



